<template>
    <div>
        <el-table
            ref="currencyTable"
            :data="tableData"
            stripe
            border
            v-loading="loading"
            style="width: 100%"
            @selection-change="getSelectVal"
        >
            <el-table-column
                type="selection"
                width="55"
                align="center"
            ></el-table-column>
            <el-table-column
                type="index"
                width="55"
                label="序号"
                align="center"
            />
            <el-table-column prop="customerName" label="客户名称">
            </el-table-column>
            <el-table-column prop="customerAttributeId" label="客户属性">
            </el-table-column>
            <el-table-column prop="telPhone" label="电话"></el-table-column>
            <el-table-column
                prop="companyId"
                label="上级公司"
            ></el-table-column>
            <el-table-column prop="provinceName" label="省份"></el-table-column>
            <el-table-column prop="cityName" label="城市"></el-table-column>
            <el-table-column prop="countyName" label="区县"></el-table-column>
            <el-table-column prop="address" label="详细地址"></el-table-column>
            <el-table-column prop="remarks" label="备注"></el-table-column>
            <el-table-column
                prop="createTime"
                label="创建日期"
            ></el-table-column>
        </el-table>
        <el-pagination
            class="pagination mt10"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
            :current-page="page"
            :page-sizes="[10, 20, 30, 40]"
            :page-size="limit"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            background
        >
        </el-pagination>
    </div>
</template>

<script>
import { getCustomerList } from "@/api/base/data";
export default {
    data() {
        return {
            tableData: [],
            page: 1, //当前页
            limit: 10, //每页条数
            total: 0,
            loading: false,
        };
    },
    methods: {
        //分页器size
        handleSizeChange(val) {
            this.limit = val;
            this.getDataList();
        },
        //分页器当前页
        handleCurrentChange(val) {
            this.page = val;
            this.getDataList();
        },
        getSelectVal(val) {
            if (val.length) {
                this.$emit("update:visible", false);
                this.$emit("getSelectVal", val);
            }
        },
        getDataList() {
            this.loading = true;
            let params = {
                page: this.page,
                limit: this.limit,
                state: 2,
                isUsed: 0,
                type: 3,
            };
            getCustomerList(params).then((res) => {
                this.tableData = res.rows;
                this.total = res.total;
                this.loading = false;
            });
        },
    },
    mounted() {
        this.getDataList();
    },
};
</script>

<style></style>
